﻿Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace FontSizeWidget
	''' <summary>
	''' Interaction logic for FontSize.xaml
	''' </summary>
	Partial Public Class FontSize
		Inherits UserControl
        Private mSize As Double

        Public Sub New()
            InitializeComponent()
            Me.ForceCursor = True
        End Sub

        Public Property Size As Double
            Get
                Return mSize
            End Get
            Set(ByVal value As Double)
                mSize = value
                Dispatcher.Invoke(New Action(Sub() UpdateFontSize(mSize)))
            End Set
        End Property

        Private Sub UpdateFontSize(ByVal size As Double)
            SizeMessage.Text = String.Format("{0}px", size)
        End Sub

        Public Property Advice As String
            Get
                Return Message.Text
            End Get
            Set(ByVal value As String)
                Dispatcher.Invoke(New Action(Sub() UpdateMessageText(value)))
            End Set
        End Property

        Private Sub UpdateMessageText(ByVal value As String)
            Message.Text = value
        End Sub

        Public Event BigAClicked As EventHandler

        Public Event SmallAClicked As EventHandler

        Private Sub BigAButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles BigAButton.Click
            RaiseEvent BigAClicked(sender, New EventArgs)
            Advice = String.Empty
        End Sub

        Private Sub SmallAButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles SmallAButton.Click
            RaiseEvent SmallAClicked(sender, New EventArgs)
            Advice = String.Empty
        End Sub

        Private Sub BigAButton_MouseEnter() Handles BigAButton.MouseEnter
            Mouse.OverrideCursor = Cursors.Hand
        End Sub

        Private Sub BigAButton_MouseLeave() Handles BigAButton.MouseLeave
            Mouse.OverrideCursor = Nothing
        End Sub

        Private Sub SmallAButton_MouseEnter() Handles SmallAButton.MouseEnter
            Mouse.OverrideCursor = Cursors.Hand
        End Sub

        Private Sub SmallAButton_MouseLeave() Handles SmallAButton.MouseLeave
            Mouse.OverrideCursor = Nothing
        End Sub

    End Class
End Namespace
